package com.cx.base.other;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

class TestClass {
    private String a;
    private String b;
}

public class Other{
    public static void main(String[] args) throws JsonProcessingException {
        List list = new ArrayList<>();
        list.add(new TestClass());
        List list2 = new ArrayList<>();
        list2.add(null);
        List list3 = new ArrayList<>();
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false);
        System.out.println(objectMapper.writeValueAsString(list)+": 空值校验"+ ObjectUtils.isEmpty(list));
        System.out.println(objectMapper.writeValueAsString(list2)+": 空值校验"+ ObjectUtils.isEmpty(list2));
        System.out.println(objectMapper.writeValueAsString(list3)+": 空值校验"+ ObjectUtils.isEmpty(list3));

    }
}
